<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="昵称">
              <a-input placeholder="请输入昵称" v-model="queryParam.nickName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="真实姓名">
              <a-input placeholder="请输入真实姓名" v-model="queryParam.realName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="手机号">
              <a-input placeholder="请输入手机号" v-model="queryParam.phone"></a-input>
            </a-form-item>
          </a-col>
          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户来源">
              <a-select ref="select" placeholder="请选择用户来源" v-model="queryParam.source" style="width: 220px">
                <a-select-option value="1">客户端</a-select-option>
                <a-select-option value="2">驻场端</a-select-option>
                <a-select-option value="3">司机端</a-select-option>
              </a-select>
            </a-form-item>
          </a-col> -->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
          style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
        :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange">
        <span slot="source" slot-scope="text, record">
          {{record.source==1?'客户端':record.source==2?'驻场端':'司机端'}}
        </span>
        <span slot="avatarUrl" slot-scope="text, record">
          <img :src="record.avatarUrl" style="width: 100px;height: 100px;" />
        </span>
        <span slot="workFlag" slot-scope="text, record">
          {{record.workFlag==1?'在线':'不在线'}}
        </span>
        <span slot="delFlag" slot-scope="text, record">
          {{record.delFlag==1?'正常':'已封禁'}}
        </span>
        <span slot="realFlag" slot-scope="text, record">
          {{record.realFlag==1?'已入驻':'未入驻'}}
        </span>
        <span slot="yhkNum" slot-scope="text, record">
          <div v-if='record.yhkUserName && record.yhkNum && recrod.yhkKhh && record.yhkPhone'>
            {{record.yhkUserName+'-'+record.yhkPhone+'-'+record.yhkKhh+'-'+record.yhkNum}}
          </div>
        </span>
        <span slot="authFlag" slot-scope="text, record">
          {{record.authFlag==0?'未提交认证':record.authFlag==1?'已认证':record.authFlag==2?'待审核':'审核驳回'}}
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a @click="handleEditGj(record.id)">轨迹订单</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <ysyUsers-modal ref="modalForm" @ok="modalFormOk"></ysyUsers-modal>
    <YsyDrivingTrackListModal ref="modalForm1" @ok="modalFormOk"></YsyDrivingTrackListModal>
  </a-card>
</template>

<script>
  import YsyUsersModal from './modules/YsyUsersModal'
  import YsyDrivingTrackListModal from './modules/YsyDrivingTrackListModal.vue'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'

  export default {
    name: "YsyUsersList",
    mixins: [JeecgListMixin],
    components: {
      YsyUsersModal,
      YsyDrivingTrackListModal
    },
    data() {
      return {
        description: '小程序用户表管理页面',
        // 表头
        columns: [{
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender: function(t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '昵称',
            align: "center",
            dataIndex: 'nickName'
          },
          {
            title: '头像',
            align: "center",
            dataIndex: 'avatarUrl',
            scopedSlots: {
              customRender: 'avatarUrl'
            },
          },
          {
            title: '用户手机号',
            align: "center",
            dataIndex: 'phone'
          },
          {
            title: '真实姓名',
            align: "center",
            dataIndex: 'realName'
          },
          // {
          //   title: '身份证正面',
          //   align: "center",
          //   dataIndex: 'frondCard'
          // },
          // {
          //   title: '身份证反面',
          //   align: "center",
          //   dataIndex: 'backCard'
          // },
          // {
          //   title: '入驻驻场端',
          //   align: "center",
          //   dataIndex: 'realFlag',
          //   scopedSlots: {
          //     customRender: 'realFlag'
          //   },
          // },
          // {
          //   title: '封禁状态',
          //   align: "center",
          //   dataIndex: 'delFlag'
          // },
          // {
          //   title: '是否是会员：1-是，0-否',
          //   align: "center",
          //   dataIndex: 'isMember'
          // },
          // {
          //   title: '会员到期时间',
          //   align: "center",
          //   dataIndex: 'expireTime'
          // },
          // {
          //   title: '折扣',
          //   align: "center",
          //   dataIndex: 'discount'
          // },
          // {
          //   title: '省份',
          //   align: "center",
          //   dataIndex: 'province'
          // },
          // {
          //   title: '城市',
          //   align: "center",
          //   dataIndex: 'city'
          // },
          // {
          //   title: '区',
          //   align: "center",
          //   dataIndex: 'area'
          // },
          // {
          //   title: '用户来源',
          //   align: "center",
          //   dataIndex: 'source',
          //   scopedSlots: {
          //     customRender: 'source'
          //   },
          // },
          {
            title: '注册时间',
            align: "center",
            dataIndex: 'createTime',
          },
          {
            title: '封车次数',
            align: "center",
            dataIndex: 'sealCarNum',
          },
          {
            title: '行车轨迹次数',
            align: "center",
            dataIndex: 'drivingTrackNum',
          },
          {
            title: '提现银行卡信息',
            align: "center",
            dataIndex: 'yhkNum',
            scopedSlots: {
              customRender: 'yhkNum'
            },
          },
          {
            title: '实名认证状态',
            align: "center",
            dataIndex: 'auth_flag',
            scopedSlots: {
              customRender: 'authFlag'
            },
          },
          // {
          //   title: '在线状态',
          //   align: "center",
          //   dataIndex: 'workFlag',
          //   scopedSlots: {
          //     customRender: 'workFlag'
          //   },
          // },
          // {
          //   title: '余额',
          //   align: "center",
          //   dataIndex: 'balance',
          // },
          // {
          //   title: '信用分',
          //   align: "center",
          //   dataIndex: 'creditScore',
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {
              customRender: 'action'
            },
          }
        ],
        url: {
          list: "/app/ysyUsers/userList",
          delete: "/app/ysyUsers/delete",
          deleteBatch: "/app/ysyUsers/deleteBatch",
          exportXlsUrl: "app/ysyUsers/exportXls",
          importExcelUrl: "app/ysyUsers/importExcel",
        },
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    mounted() {},
    methods: {
      handleEditGj(userId) {
        this.$refs.modalForm1.edit(userId)
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>